package jdk8;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class FutureTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> "Hello").thenApply((s) -> s + " ").thenApply((s) -> s + "world");
        System.out.println(future.get());
        CompletableFuture.supplyAsync(() -> "Hello").thenApply((s) -> s + " ").thenApply((s) -> s + "world").whenComplete((s, e) -> System.out.println(s));
    }
}
